<%@page import="common.SerialDAO"%>
<%@page import="common.SerialDTO"%>
<%@page import="comment.CommentVo"%>
<%@page import="java.util.ArrayList"%>
<%@page import="comment.CommentMyBa"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="Board.BoardVo"%>
<%@page import="Board.BoardMyba"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>게시판 상세화면</title>
<link rel="stylesheet"
	href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<!-- <script type="text/javascript"
	src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> -->
<style>
#view_main {
	width: 900px;
	margin: auto;
	margin-top: 40px;
	border: 1px solid #dddddd;
	font-family: 나눔바른고딕;
	/* border: 2px solid #000000; */
}

/*--------------------------------제목---------------------------------*/
#view_subject_box {
	width: 880px;
	margin: 0 auto;
}

#view_subject,#view_date {
	display: inline-block;
	padding-top: 10px;
	padding-bottom: 3px;
	font-size: 10pt;
}

#view_subject {
	float: left;
	font-weight: bold;
	padding-left: 8px;
}

#view_date {
	float: right;
}

#view_line {
	clear: both;
	width: 880px;
	border-bottom: 1px dashed #dddddd;
}

/*------------------------------------Board----------------------------*/
#view_content_box {
	width: 880px;
	margin: 0 auto;
	font-size: 10pt;
	font-weight: bold;
}

#view_content_co_st {
	padding-top: 10px;
	padding-left: 8px;
	float: left;
}

#view_line2 {
	padding-top: 20px;
	width: 880px;
	clear: both;
}

#view_content_file {
	/*float:right;*/
	padding-top: 5px;
	padding-bottom: 3px;
	width: 880px;
	margin: 0 auto;
	border-bottom: 1px dashed #dddddd;
}

#view_content_file_subject,#view_content_file_name {
	display: inline-block;
	font-size: 10pt;
}

#file_box {
	color : black;
	text-decoration: none;
}
#view_content_file_name a:hover{
	font-size: 10pt;
	font-weight: bold;
}

#view_content_file_subject {
	padding-left: 8px;
}
#history{
	cursor : pointer;
}
/*----------------------------------Content----------------------------*/
#view_content_view_box {
	width: 880px;
	margin: 0 auto;
	margin-bottom: 10px;
}

#view_content_content {
	padding-left: 8px;
	font-size: 10pt;
	padding-bottom: 10px;
}

/*------------------------------------수정/삭제/목록-------------------*/
#insert_list_delete_box {
	margin: 0 auto;
	width: 900px;
	padding-bottom: 5px;
	height: 15px;
}

#insert_list_delete {
	font-size: 10pt;
	text-align: right;
}

#insert_list_delete a {
	text-decoration: none;
	vertical-align: middle;
	color: black;
	display: inline-block;
	padding-bottom: 5px;
	padding-right: 5px;
}

#insert_list_delete a:hover {
	text-decoration: underline;
}

/* -------- 댓글 스타일 ------------  */


#repl_dashed_line {
	width: 900px;
	clear: both;
	border-top: 1px dashed #dddddd;
}

#repl_top {
	text-align: center;
}

#repl_top_text {
	font-size: 13px;
	font-weight: bolder;
	color: #333333;
	padding: 10px 0px 5px 0px;
}

#repl_top_text2 {
	font-size: 11px;
	color: #888888;
	padding: 0px 0px 10px 0px;
}

#repl_box,#repl_regi_btn {
	display: inline-block;
	vertical-align: middle;
}
/*-----댓글버튼-------  */
#btnComment {
	width: 80px;
	height: 40px;
	color: #ffffff;
	font-weight: bold;
	background-color: #c21504;
	border: none;
	padding: 3px 5px;
	cursor: pointer;
}

#repl_input {
	/* margin: 0 auto; */
	text-align: center;
	margin-top: 10px;
}

</style>

<script>
	function del(bo_no) {
		var v = confirm("삭제하시겠습니까?");
		if (v) {
			location.href = 'index.jsp?inc_content=./board/board_delete.jsp&bo_no='
					+ bo_no;
		} else {
			confirm("삭제가 취소되었습니다.");
		}
	}

	function modi(bo_no) {
		location.href = 'index.jsp?inc_content=./board/board_modify.jsp&bo_no='
				+ bo_no;
		/*&bo_part='+part+'*/
	}

	function list(part,nowPage,text) {
		//var la = document.getElementById("fi").value;
		
		location.href = 'index.jsp?inc_content=./board/board_list.jsp&bo_part='
				+ part+'&nowPage='+nowPage+'&text_find='+text;
	}

	function FileDown(bo_file) {
		url = '${pageContext.request.contextPath}/homepage/board/fileDownload.jsp?filename='
				+ bo_file;
		window.open(url, "win", "");
	}
</script>


<!-- ---------------코멘트 스크립트~!!---------------------  -->
<script>
	function init() {
		var params = "BO_no=" + $('#bbb').val();
		$
				.ajax({
					url : '${pageContext.request.contextPath}/homepage/board/comment_list2.jsp',
					type : 'POST',
					cache : false,
					data : params,
					success : function(html) {
						$("#comment_result").html(html);
					}
				});
	}

	function replRegi() {
		var tf = document.getElementById("content111");
		var tfv = document.getElementById("content111").value;
		var aa = tfv.trim();
		if(aa = null || aa == ""){
			alert("빈칸을 입력해주세요");
			tf.value = "";
			tf.focus();
			return false;
		}else{		
			var params = "BO_no=" + $('#bbb').val(); //인서트할때 쿼리 날리는거 다 넘기기..
			params = params + "&CO_content=" + $('#content111').val();
			/* params = params + "&CO_no=" + $('#qqqq').val(); */
			params = params + "&SA_no=" + $('#rrrr').val();
			params = params + "&SA_nm=" + $('#yyyy').val();
	
			$
					.ajax({
						url : '${pageContext.request.contextPath}/homepage/board/comment_list2.jsp',
						type : 'POST',
						cache : false,
						data : params,
						success : function(html) {
							$("#comment_result").html(html);
							/* alert("success"); */
						}
					});
			tf.value = "";
			tf.focus();
		}
	}
</script>




</head>
<body>
	<jsp:useBean id="boardVo" class="Board.BoardVo" />
	<jsp:setProperty property="*" name="boardVo" />
	<%
	String app = (String)application.getAttribute("sa_no");
	
	
	
	BoardMyba board = new BoardMyba();
	String qqq = request.getParameter("text_find");
	if(qqq != null){
		boardVo.setText_find(request.getParameter("text_find"));
	}else{
		boardVo.setText_find("");
	}
	
	String fff = request.getParameter("nowPage");
	if(fff != null){
		board.setNowPage(Integer.parseInt(request.getParameter("nowPage")));
	}else{
		board.setNowPage(1);
	}
	
	
	
	board.setVo(boardVo);
	BoardVo view = board.view();
	
	%>

	<%
	CommentMyBa comment = new CommentMyBa();
	comment.setBO_no(boardVo.getBo_no());
	/* out.print(comment.getBO_no()); */
	comment.setSA_nm((String)session.getAttribute("SA_nm"));  //사원이름 코멘트 테이블에 추가 해서 세션에 있는걸 넣어줌
	/* ArrayList<CommentVo> list = comment.list(); */

	
	String mid = (String) session.getAttribute("Mid");
	String SA_no = (String)session.getAttribute("SA_no");

	%>
	<form method='post' enctype='multipart/form-data' action=''>
	<input type = 'hidden' name = 'nowPage' value = '<%=board.getNowPage() %>'>
		<c:set var="vo" value="<%=view%>"></c:set>
		<div id="view_main">
			<input type='hidden' name='bo_no' value='<%=boardVo.getBo_no()%>'>
			<div id='view_subject_box'>
				<div id='view_subject'><%=view.getBo_title()%></div>
				<%
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
						//시간을변환하는 simpledataformat
				%>
				<div id='view_date'><%=sdf.format(view.getRg_dt())%></div>
				<div id='view_line'></div>
			</div>
			<%
				if(view.getBo_file() == null || view.getBo_file().equals("")){
			%>
			<div id='view_content_file'>
				<div id='view_content_file_subject'>파일첨부:</div>
				<div id='view_content_file_name'>NO_FILE</div>
				<%
					}else{
				%>
				<div id='view_content_file'>
					<div id='view_content_file_subject'>파일첨부:</div>
					<div id='view_content_file_name'>
						<a href="#" onclick="FileDown('<%=view.getBo_file()%>')" id = 'file_box'><%=view.getBo_file()%></a>

					</div>
					<%
						}
					%>
				</div>
				<div id='view_content_box'>
					<div id='view_content_co_st'><%=view.getSa_nm()%></div>
					<div id='view_line2'></div>
				</div>
				<div id='view_content_view_box'>
					<div id='view_content_content'><%=view.getBo_content()%></div>
				</div>
				<div id='insert_list_delete_box'>
					<div id='insert_list_delete'>
						<%
							if(mid.equals(view.getSa_no())){
						%>
						<a href='#' onclick="modi('<%=view.getBo_no()%>')">수정</a>| <a
							href='#' onclick="del('<%=view.getBo_no()%>')">삭제</a>| <a
							 onclick="list('<%=view.getBo_part() %>', '<%=board.getNowPage() %>','<%=boardVo.getText_find() %>')" id = 'history'>목록</a>
						<%
							}else{
						%>
						<a onclick="list('<%=view.getBo_part() %>', '<%=board.getNowPage() %>','<%=boardVo.getText_find() %>')" id = 'history'>목록</a>
						<%
							}
						%>
					</div>
				</div>
				<div id='clear_both'></div>
			</div>
		</div>
	</form>

	<!-- ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ코멘트화면ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ  -->
	<div style="clear:both;"></div>
	<div style="height: 20px;"></div>
	<div id='comment_box1' align="center">
			<div id="repl_top">
				<div id="repl_dashed_line" style="width:800px;margin:0 auto;"></div>
				<div id="repl_top_text">COMMENT</div>
				<div id="repl_top_text2">코멘트 댓글을 입력해주세요.</div>
				<div id="repl_dashed_line" style="width:800px;margin:0 auto;"></div>
			</div>

			<form name="repl_frm" action='' method='post'>
				<div id="repl_input">
					<div id="repl_box">
						<textarea rows="4" cols="80" style="resize: none;"
							name="CO_content" id="content111"></textarea>
					</div>
					<div id="repl_regi_btn">
						<input id="btnComment" type="button" value="등록"
							onclick="replRegi()">
					</div>
					<%-- <input type="hidden" value="<%=temp%>" name="CO_no" id="qqqq"> --%>
					<input type="hidden" value="<%=comment.getBO_no()%>" id="bbb" name="BO_no"> 
					<input type="hidden" value="<%=SA_no%>"name="SA_no" id="rrrr">
					<input type="hidden" value="<%=comment.getSA_nm()%>" name="SA_nm" id="yyyy">
				</div>
			</form>
			<div style="height: 20px;"></div>

			<div id="comment_result"></div>

			<div style="height: 20px;"></div>
			<div style="height: 20px;"></div>
		</div>

	<script>
		init()
	</script>
</body>
</html>



